﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace LOLApi.Models
{
    public class Rank
    {
        //单双排
        public RANKED_SOLO_5x5 ?RANKED_SOLO_5x5 { get; set; }
        //灵活
        public RANKED_FLEX_SR ? RANKED_FLEX_SR { get; set; }
        //云顶
        public RANKED_TFT? RANKED_TFT { get; set; }
    }

    public class RankedEntry
    {

        public string? Division { get; set; }

        public int LeaguePoints { get; set; }

        public int Losses { get; set; }

        public int Wins { get; set; }

        public string? Tier { get; set; }
        public string CnTier => Tier?.ToUpper() switch
        {
            "CHALLENGER" => "王者",
            "GRANDMASTER" => "宗师",
            "MASTER" => "大师",
            "DIAMOND" => "钻石",
            "EMERALD" => "翡翠",
            "PLATINUM" => "铂金",
            "GOLD" => "黄金",
            "SILVER" => "白银",
            "BRONZE" => "青铜",
            "IRON" => "黑铁",
            _ => "未定"
        };

        public string PreCnTier => PreviousSeasonEndTier?.ToUpper() switch
        {
            "CHALLENGER" => "王者",
            "GRANDMASTER" => "宗师",
            "MASTER" => "大师",
            "DIAMOND" => "钻石",
            "EMERALD" => "翡翠",
            "PLATINUM" => "铂金",
            "GOLD" => "黄金",
            "SILVER" => "白银",
            "BRONZE" => "青铜",
            "IRON" => "黑铁",
            _ => "未定"
        };
        public string? PreviousSeasonEndDivision { get; set; }
        public string? PreviousSeasonEndTier { get; set; }

        public virtual string GameMode { get; } = "Default Ranked Entry";
        public string TierAndDivision => CnTier+"  "+Division;
        public string WinRate => Wins + Losses <= 0 ? "暂无" : $"{(Wins * 100.0 / (Wins + Losses)).ToString("0.00")}%";
    }

    public class RANKED_FLEX_SR : RankedEntry
    {
        public override string GameMode => "灵活组排";
    }

    public class RANKED_SOLO_5x5 : RankedEntry
    {
        public override string GameMode => "单双排";
    }

    public class RANKED_TFT : RankedEntry
    {
        public override string GameMode => "云顶之奕";
    }
}
